package com.pw.study.flink.demo

import org.apache.flink.streaming.api.scala._

object WordCountV2_UnBoundedStream {
  def main(args: Array[String]): Unit = {
    //1.初始化环境
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
    //2.输入数据
    val ds: DataStream[String] = env.socketTextStream("localhost", 9999)
    //3.处理数据
    val dealData: DataStream[(String, Int)] = ds.flatMap(_.split("")).map((_, 1)).keyBy(_._1).sum(1)
    //4.输出数据
    dealData.print("数据：")

    //5.执行
    env.execute()

  }
}
